<template>
	<view>
		<view class="container u-skeleton">
			<view class="userinfo">
				<block>
					<!--u-skeleton-circle 绘制圆形-->
					<image class="userinfo-avatar u-skeleton-circle" :src="userInfo.avatarUrl"></image>
					<!--u-skeleton-fillet 绘制圆角矩形-->
					<text class="u-skeleton-fillet">{{userInfo.nickName}}</text>
				</block>
			</view>
			<view style="margin: 20px 0">
				<view class="lists">
					<text class="u-skeleton-rect">手机型号：{{lists.model}}</text>
				</view>
				<view class="lists">
					<text class="u-skeleton-rect">系统版本：{{lists.system}}</text>
				</view> 
				<view class="lists">
					<text class="u-skeleton-rect">系统语言：{{lists.language}}</text>
				</view><view class="lists">
					<text class="u-skeleton-rect">手机屏幕宽/高：{{lists.screenWidth}}/{{lists.screenHeight}}</text>
				</view>
			</view>
			<u-toast ref="uToast"/>
		</view>
		<!--引用组件-->
		<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 随意填充一些模拟数据，以撑开元素，供骨架组件查询和模拟块状数据
				userInfo: {
					avatarUrl: '/static/image/isme.jpg',
					nickName: '楚凤沛的Huawei P40'
				},
				lists: {},
				loading: true, // 是否显示骨架屏组件
			}
		},
		mounted(){
		},
		onLoad() {
			var that = this;
			// 获取系统信息
			uni.getSystemInfo({
				success(res){
					that.lists = res;
					that.$forceUpdate()
					console.log('系统信息：',res)
					// that.$refs.uToast.show({
					// 	title: '获取系统信息成功！',
					// 	type: 'success',
					// 	position: "bottom"
					// })
				},
				fail(){
					alert('失败')
				}
			})
			// 通过延时模拟向后端请求数据，调隐藏骨架屏
			setTimeout(() => {
				this.loading = false;
			}, 2000)
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 20rpx 60rpx;
	}

	.userinfo {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.userinfo-avatar {
		width: 168rpx;
		height: 168rpx;
		margin: 20rpx;
		border-radius: 50%;
	}

	.lists {
		width:100%;
		margin: 10px 0;
		text-align: center;
	}
</style>